home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / GMS / GMSDev / Source / Asm / Screens / ResizeWorm.s < prev   
Encoding:
Text File  |  1998-05-09  |  6.6 KB  |  297 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;This version of the Worm demo opens a 640x512 screen and resizes the 320x256
  3. ;background to fit this screen mode.  Then it blits the worm on top, which
  4. ;appears at half its normal size because of the change of resolution.
  5. ;
  6. ;You can change the resolution if you like, just edit the settings below.
  7.  
  8. SCREENWIDTH   = 320/2    ;Factor of 16
  9. SCREENHEIGHT  =    256/2
  10. SCREENMODE    =    SM_HIRES|SM_LACED
  11. SCREENCOLOURS =    32
  12.  
  13.     INCDIR    "GMSDev:Includes/"
  14.     INCLUDE    "dpkernel/dpkernel.i"
  15.  
  16.     SECTION    "Demo",CODE
  17.  
  18. ;===========================================================================;
  19. ;                             INITIALISE DEMO
  20. ;===========================================================================;
  21.  
  22.     STARTDPK
  23.  
  24. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  25.     move.l    DPKBase(pc),a6
  26.     lea    ScreenTags(pc),a0
  27.     sub.l    a1,a1
  28.     CALL    Init
  29.     tst.l    d0
  30.     beq    .Exit
  31.  
  32. ;---------------------------------------------------------------------------;
  33. ;Load a picture into the background of the screen.  We have to set the
  34. ;correct palette and copy it to our second buffer as part of this process.
  35.  
  36.     lea    PIC_BackgroundTags(pc),a0
  37.     sub.l    a1,a1
  38.     CALL    Init
  39.     tst.l    d0
  40.     beq    .Exit
  41.  
  42.     move.l    SCRBase(pc),a6
  43.     move.l    Screen(pc),a0
  44.     move.l    GS_Bitmap(a0),a3
  45.     move.l    PIC_Background(pc),a1
  46.     move.l    PIC_Bitmap(a1),a2
  47.     move.l    BMP_Palette(a2),BMP_Palette(a3)
  48.     CALL    scrUpdatePalette
  49.  
  50.     move.l    DPKBase(pc),a6
  51.     move.l    PIC_Background(pc),a0
  52.     move.l    PIC_Bitmap(a0),a0
  53.     move.l    Screen(pc),a1
  54.     move.l    GS_Bitmap(a1),a1
  55.     CALL    Copy
  56.  
  57.     move.l    BLTBase(pc),a6
  58.     move.l    Screen(pc),a0
  59.     moveq    #BUFFER2,d0
  60.     moveq    #BUFFER1,d1
  61.     CALL    bltCopyBuffer
  62.  
  63. ;---------------------------------------------------------------------------;
  64. ;Initialise the restore object.
  65.  
  66.     move.l    DPKBase(pc),a6
  67.     lea    RestoreTags(pc),a0
  68.     move.l    Screen(pc),a1    ;a1 = Screen.
  69.     move.l    GS_Bitmap(a1),RBitmap    ;ma = Bitmap for restore list.
  70.     CALL    Init    ;>> = Initialise the restore list.
  71.     tst.l    d0    ;d0 = Check for errors.
  72.     beq.s    .Exit    ;>> = Error, exit.
  73.  
  74. ;---------------------------------------------------------------------------;
  75. ;Load the bob file in.  This contains the graphics data that we are going to
  76. ;draw to the screen.
  77.  
  78.     lea    BBT_Rambo(pc),a0
  79.     move.l    Screen(pc),a1
  80.     CALL    Init
  81.     tst.l    d0
  82.     beq.s    .Exit
  83.  
  84.     lea    SMT_Rambo(pc),a0
  85.     sub.l    a1,a1
  86.     CALL    Init
  87.     tst.l    d0
  88.     beq.s    .Exit
  89.  
  90.     moveq    #ID_JOYDATA,d0    ;Get joydata structure.
  91.     CALL    Get
  92.     move.l    d0,JoyData
  93.     beq.s    .Exit
  94.     move.l    d0,a0    ;Initialise the joydata structure.
  95.     sub.l    a1,a1
  96.     CALL    Init
  97.     tst.l    d0
  98.     beq.s    .Exit
  99.  
  100.     move.l    Screen(pc),a0
  101.     CALL    Display
  102.  
  103.     bsr.s    Main
  104.  
  105. .Exit    move.l    DPKBase(pc),a6
  106.     move.l    JoyData(pc),a0
  107.     CALL    Free
  108.     move.l    SND_Rambo(pc),a0
  109.     CALL    Free
  110.     move.l    BOB_Rambo(pc),a0
  111.     CALL    Free
  112.     move.l    Restore(pc),a0
  113.     CALL    Free
  114.     move.l    PIC_Background(pc),a0
  115.     CALL    Free
  116.     move.l    Screen(pc),a0
  117.     CALL    Free
  118.     MOVEM.L    (SP)+,A0-A6/D1-D7
  119.     moveq    #ERR_OK,d0
  120.     rts
  121.  
  122. ;===========================================================================;
  123. ;                                MAIN LOOP
  124. ;===========================================================================;
  125.  
  126. SPEED    =    5
  127. FIRESPEED =    0
  128.  
  129. Main:    moveq    #$00,d7
  130.  
  131. .Loop    move.l    DPKBase(pc),a6
  132.     move.l    Restore(pc),a0
  133.     CALL    Activate
  134.  
  135.     move.l    BOB_Rambo(pc),a0
  136.     CALL    Draw    ;Blit the bob.
  137.  
  138.     move.l    SCRBase(pc),a6
  139.     CALL    scrWaitAVBL
  140.  
  141.     move.l    Screen(pc),a0
  142.     CALL    scrSwapBuffers
  143.  
  144.     addq.w    #1,d7
  145.  
  146.     move.l    DPKBase(pc),a6
  147.     move.l    BOB_Rambo(pc),a1
  148.     tst.b    FireState
  149.     bne.s    .FireOn
  150.  
  151.     cmp.w    #SPEED,d7
  152.     ble.s    .Move
  153.     moveq    #$00,d7
  154.     addq.w    #1,BOB_Frame(a1)
  155.     cmp.w    #9,BOB_Frame(a1)
  156.     blt.s    .Move
  157.     clr.w    BOB_Frame(a1)
  158.     bra.s    .Move
  159.  
  160. .FireOn    cmp.w    #FIRESPEED,d7
  161.     ble.s    .Move
  162.     moveq    #$00,d7
  163.     cmp.w    #10,BOB_Frame(a1)
  164.     bge.s    .On
  165.     move.w    #9,BOB_Frame(a1)
  166.  
  167. .On    addq.w    #1,BOB_Frame(a1)
  168.     cmp.w    #13,BOB_Frame(a1)
  169.     blt.s    .Move
  170.     clr.w    BOB_Frame(a1)
  171.     clr.b    FireState
  172.     move.l    SND_Rambo(pc),a0
  173.     CALL    Activate
  174.  
  175. .Move    move.l    JoyData(pc),a0
  176.     CALL    Query
  177.     move.l    JoyData(pc),a0
  178.     move.l    BOB_Rambo(pc),a1
  179.     move.w    JD_XChange(a0),d0
  180.     add.w    d0,BOB_XCoord(a1)
  181.     move.w    JD_YChange(a0),d0
  182.     add.w    d0,BOB_YCoord(a1)
  183.     move.l    JD_Buttons(a0),d0
  184.     btst    #JB_LMB,d0
  185.     beq.s    .chkRMB
  186.     st    FireState    ;Set fire to on.
  187. .chkRMB    btst    #JB_RMB,d0
  188.     beq    .Loop
  189.     rts
  190.  
  191. FireState:
  192.     dc.b    0
  193.     even
  194.  
  195. ;===========================================================================;
  196. ;                                  DATA
  197. ;===========================================================================;
  198.  
  199. JoyData:    dc.l  0
  200.  
  201. ;---------------------------------------------------------------------------;
  202.  
  203. RestoreTags:    dc.l  TAGS_RESTORE
  204. Restore:    dc.l  0
  205.         dc.l  RSA_Owner
  206. RBitmap:    dc.l  0
  207.         dc.l  RSA_Entries,1
  208.         dc.l  RSA_Buffers,2
  209.         dc.l  TAGEND
  210.  
  211. ;---------------------------------------------------------------------------;
  212.  
  213. ScreenTags:    dc.l  TAGS_SCREEN
  214. Screen:        dc.l  0
  215.         dc.l  GSA_Width,SCREENWIDTH
  216.         dc.l  GSA_Height,SCREENHEIGHT
  217.         dc.l    GSA_BitmapTags,0
  218.         dc.l    BMA_AmtColours,SCREENCOLOURS
  219.         dc.l    TAGEND,0
  220.         dc.l  GSA_Attrib,SCR_DBLBUFFER|SCR_CENTRE
  221.         dc.l  GSA_ScrMode,SCREENMODE
  222.         dc.l  TAGEND
  223.  
  224. ;---------------------------------------------------------------------------;
  225.  
  226. PIC_BackgroundTags:
  227.         dc.l  TAGS_PICTURE
  228. PIC_Background:    dc.l  0
  229.         dc.l    PCA_BitmapTags,0
  230.         dc.l    BMA_Data
  231. Data:        dc.l    0
  232.         dc.l    BMA_Width,SCREENWIDTH
  233.         dc.l    BMA_Height,SCREENHEIGHT
  234.         dc.l    BMA_AmtColours,SCREENCOLOURS
  235.         dc.l    TAGEND,0
  236.         dc.l  PCA_ScrMode,SCREENMODE
  237.         dc.l  PCA_Options,IMG_RESIZE
  238.         dc.l  PCA_Source,.file
  239.         dc.l  TAGEND
  240.  
  241. .file        FILENAME "GMS:demos/data/PIC.Green"
  242.  
  243. ;---------------------------------------------------------------------------;
  244.  
  245. BBT_Rambo:    dc.l  TAGS_BOB
  246. BOB_Rambo:    dc.l  0
  247.         dc.l  BBA_GfxCoords,.frames
  248.         dc.l  BBA_Width,32
  249.         dc.l  BBA_Height,24
  250.         dc.l  BBA_XCoord,50
  251.         dc.l  BBA_YCoord,50
  252.         dc.l  BBA_Attrib,BBF_GENMASKS|BBF_CLIP|BBF_RESTORE
  253.         dc.l    BBA_SourceTags,ID_PICTURE
  254.         dc.l      PCA_BitmapTags,0
  255.         dc.l      BMA_MemType,MEM_BLIT
  256.         dc.l      TAGEND,0
  257.         dc.l    PCA_Source,.file
  258.         dc.l    TAGEND,0
  259.         dc.l  TAGEND
  260.  
  261. .frames        dc.w    0,00 ;X/Y Graphic
  262.         dc.w   32,00 ;...
  263.         dc.w   64,00
  264.         dc.w   96,00
  265.         dc.w  128,00
  266.         dc.w  160,00
  267.         dc.w  192,00
  268.         dc.w  224,00
  269.         dc.w  256,00
  270.         dc.w  288,00
  271.         dc.w    0,48
  272.         dc.w   32,48
  273.         dc.w   64,48
  274.         dc.l  -1
  275.  
  276. .file        FILENAME "GMS:demos/data/PIC.Rambo"
  277.  
  278. ;---------------------------------------------------------------------------;
  279.  
  280. SMT_Rambo:    dc.l  TAGS_SOUND
  281. SND_Rambo:    dc.l  0
  282.         dc.l  SA_Octave,OCT_C2S
  283.         dc.l  SA_Volume,100
  284.         dc.l  SA_Source,.file
  285.         dc.l  TAGEND
  286.  
  287. .file        FILENAME "GMS:demos/data/SND.Rambo"
  288.  
  289. ;===========================================================================;
  290.  
  291. ProgName:    dc.b  "Resize Worm",0
  292. ProgAuthor:    dc.b  "Paul Manias",0
  293. ProgDate:    dc.b  "May 1998",0
  294. ProgCopyright:    dc.b  "DreamWorld Productions (c) 1996-1998.  Freely distributable.",0
  295. ProgShort:    dc.b  "Resizing demonstration.",0
  296.         even
  297.